<template>
  <teleport to="body">
    <div class="tip-alert-wrapper">
      <div class="alert-mask"></div>
      <div class="alert-container">
        <div class="header">
          <div class="title">{{ title }}</div>
          <el-icon @click="$emit('close')" class="close-btn"><Close /></el-icon>
        </div>
        <div class="content">{{ content }}</div>
        <div class="btns">
          <div class="btn cancel" @click="$emit('close')">取消</div>
          <div class="btn confirm" @click="$emit('confirm')">确定</div>
        </div>
      </div>
    </div>
  </teleport>
</template>

<script setup>
import { Close } from '@element-plus/icons-vue'

defineProps({
  title: { type: String, default: '提示' },
  content: String
})

defineEmits(['close', 'confirm'])
</script>

<style lang="less" scoped>
.tip-alert-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  width: 100%;
  height: 100%;
  user-select: none;
  .alert-mask {
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
  }
  .alert-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-sizing: border-box;
    width: 480px;
    height: 215px;
    display: flex;
    flex-direction: column;
    gap: 30px;
    padding: 30px 40px;
    border-radius: 15px;
    background-color: #fff;
    .header {
      display: flex;
      justify-content: center;
      align-items: center;
      color: #81858c;
      font-size: 20px;
      .title {
        margin-inline: auto;
        color: rgba(4, 11, 26, 0.8);
        font-size: 22px;
        font-weight: bold;
      }
      .close-btn {
        cursor: pointer;
      }
    }
    .content {
      color: rgba(4, 11, 26, 0.7);
      font-size: @size-big;
      text-align: center;
    }
    .btns {
      display: flex;
      justify-content: space-around;
      gap: 35px;
      .btn {
        padding: 7px 49px;
        font-size: 20px;
        font-weight: bold;
        border-radius: 5px;
        border: 1px solid @color-brand-regular;
        cursor: pointer;
        &.cancel {
          color: @color-brand-regular;
          background-color: #fff;
        }
        &.confirm {
          color: #fff;
          background-color: @color-brand-regular;
        }
      }
    }
  }
}
</style>
